<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class UserGroupbuy extends Model
{
    protected $table = 'user_groupbuy';

    protected $guarded = ['id'];

    protected $appends = ['num'];  

    public function user()
    {
    	return $this->belongsTo(User::class);
    }

    public function getNumAttribute()
    {
    	return self::where(['code'=>$this->code])->count();
    }

    public function productGroup()
    {
        return $this->belongsTo(productGroup::class);
    }





    
}
